
#ifndef TOOLS_THREAD_TEST_POOLTESTS_HPP__
# define TOOLS_THREAD_TEST_POOLTESTS_HPP__

# include <future>
# include <functional>
# include <cstdlib>

# include "Suite.hpp"

# include "ThreadPool.hpp"

namespace Tools {
    namespace Thread {
        namespace Test {
            class Worker
            {
                public:
                    void operator()() {
                        int t = rand() % 3 + 1;
                        std::cout << "sleeping for " << t << " s" << std::endl;
                        std::this_thread::sleep_for(std::chrono::seconds(t));
                    }
            };

            class PoolTests : public ::Test::Suite<PoolTests>
            {
                void baseTest() {
                    Tools::Thread::ThreadPool<Worker> tp;
                    for (int i = 0; i < 10; ++i)
                        tp.pushTask(Worker());
                }

                public:
                    PoolTests() {
                        this->_name = "Pool tests";
                        this->addTestFunction(&PoolTests::baseTest, "Base pool test");
                    }
            };
        }
    }
}

#endif // TOOLS_THREAD_TEST_POOLTESTS_HPP__

